/**
* This source code shows how to recognize human faces with OpenCV.
*
* The author, David Qiu, designs this method and implements it in
* OpenCV. The author remains all rights of the methods, algorithms,
* and code. One can only access to the code for study purpose.
* Commercial use or releasement related to the methods, algorithms,
* or code is NOT allowed.
*
* Creative Commons: BY-NC-ND
*
* Author:  David Qiu (david@davidqiu.com)
* Website: http://www.davidqiu.com/
*/

#ifndef _FACE_RECOGNITION_HPP_
#define _FACE_RECOGNITION_HPP_

#include <opencv.hpp>
#include <highgui.h>


int FaceRecognition(int argc, char** argv)
{
  vector<Mat> images;
  vector<int> labels;
  
  // images for first person
  images.push_back(imread("person0/0.jpg", CV_LOAD_IMAGE_GRAYSCALE));
  labels.push_back(0);
  images.push_back(imread("person0/1.jpg", CV_LOAD_IMAGE_GRAYSCALE));
  labels.push_back(0);
  
  // images for second person
  images.push_back(imread("person1/0.jpg", CV_LOAD_IMAGE_GRAYSCALE));
  labels.push_back(1);
  images.push_back(imread("person1/1.jpg", CV_LOAD_IMAGE_GRAYSCALE));
  labels.push_back(1);

  // create face recognizer
  Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
  model->train(images, labels);

  // prediction
  Mat img = imread("person1/2.jpg", CV_LOAD_IMAGE_GRAYSCALE);
  int predicted = model->predict(img);
  printf("Predicted Factor = %d\n", predicted);

  return 0;
}


#endif //_FACE_RECOGNITION_HPP_
